﻿namespace SharePointCSVImporter
{
    using System;
    using System.Windows.Data;

    public class TransformationValueConverter : IValueConverter
    {
        #region Methods

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string rvalue = "N/A";
            if (value is CSVParser.FieldMapping)
            {
                CSVParser.FieldMapping map = value as CSVParser.FieldMapping;
                if (map.Transformation != null)
                {
                    rvalue = map.Transformation.TransformationType.ToString();
                }
            }
            else
            {
                if (value is CSVParser.FieldTransformation)
                {
                    if (value != null)
                    {
                        CSVParser.FieldTransformation trans = value as CSVParser.FieldTransformation;
                        rvalue = trans.TransformationType.ToString();
                    }
                }
            }
            return rvalue;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return null;
        }

        #endregion Methods
    }
}